package com.kaoshi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kaoshi.entity.Fw;
import com.kaoshi.entity.Jlb;
import com.kaoshi.mapper.FwMapper;
import com.kaoshi.mapper.JlbMapper;
import com.kaoshi.service.IFwService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-05
 */
@Service
public class FwServiceImpl extends ServiceImpl<FwMapper, Fw> implements IFwService {

    @Autowired
    private JlbMapper jlbMapper;

    @Override
    public List<Fw> getInfo(Integer id) {
        QueryWrapper<Fw> fwQueryWrapper = new QueryWrapper<>();
        fwQueryWrapper.eq("pid",id);
        fwQueryWrapper.orderByAsc("status");
        List<Fw> fws = baseMapper.selectList(fwQueryWrapper);


        for (Fw fw : fws) {
            QueryWrapper<Jlb> jlbQueryWrapper = new QueryWrapper<>();
            System.out.println(fw);
            jlbQueryWrapper.eq("pid",id);
            jlbQueryWrapper.eq("ctime",fw.getFtime());
            jlbQueryWrapper.eq("status",1);
            Jlb jlb = jlbMapper.selectOne(jlbQueryWrapper);
            System.out.println(jlb+"______________________");
            if (jlb!=null){
                fw.setJlb(jlb);
            }
        }
        return fws;
    }
}
